j3deditor.bin.hierarchy
Class J3DeGeometryArray

java.lang.Object
  extended by j3deditor.bin.hierarchy.J3DeGeometry
      extended by j3deditor.bin.hierarchy.J3DeGeometryArray

public class J3DeGeometryArray
extends J3DeGeometry

Manages Java 3D javax.media.j3d.GeometryArray object.

Author:
Risto Seene
See Also:
GeometryArray

Constructor Summary
J3DeGeometryArray(javax.media.j3d.GeometryArray geom)
          Creates an instance of J3DeGeometryArray.
 
Method Summary
 J3DeGeometryArray changeGeometryType(int vertexFormat)
          Creates new GeometryArray with the specified vertex format and vertex data from this J3DeGeometryArray.
protected  void changeValidVCount(int newValue)
          Changes the amount of valid vertices (and restructures the array of vertices (Vertex[])).
static J3DeGeometryArray createNewGeometryArray(int type, int vertexCount, int vertexFormat)
          Creates new GeometryArray with the specified properties and sets its valid vertx count to 0.
 J3DeGeometryArray createSimilarGeometryArray(int vertexCount, Vertex[] vertices)
          Creates and returns new J3DeGeometryArray which has same properties.
protected  void deleteVertices(Vertex[] vertices)
          Deletes specified vertices.
protected  float[] getColor(int index)
          Returns the color of the specified vertex.
 int getColorType()
          Returns the type of vertex colors.
protected  float[] getNormal(int index)
          Returns the vertex normal of the specified vertex.
 int getTexCoordSetCount()
          Returns the amount of texture coordinate sets.
 int getTexCoordType()
          Returns the type of texture coordinates.
protected  float[] getTextureCoordinates(int index, int[] axes, int texCoordSet)
          Returns texture coordinates of the specified vertex.
protected  float[] getVertexCoordinates(int index, int[] axes)
          Returns the coordinates of the specified vertex.
protected  int getVertexCount()
          Returns the amount of all vertices.
 int getVertexGroupMode()
          Returns vertex group mode.
 int getVertexMode()
          Returns vertex mode.
protected  Vertex[] getVertices()
          Returns all valid vertices.
 boolean hasColor()
          Returns true if vertex colors is enabled, otherwise false.
 boolean hasNormals()
          Returns true if vertex normals is enabled, otherwise false.
static void setCapabilities(javax.media.j3d.GeometryArray geom)
          Sets neccessary capability bits.
protected  void setColor(int index, float[] color)
          Sets the color of the specified vertex.
protected  void setNormal(int index, float[] coordinates)
          Sets the vertex normal of the specified vertex.
protected  void setTextureCoordinates(int index, float[] coordinates, int[] axes, int texCoordSet)
          Sets texture coordinates of the specified vertex.
protected  void setVertexCoordinates(int index, float[] coordinates, int[] axes)
          Sets the coordinates of the specified vertex.
 java.lang.String toString()
          Returns the String representation of this J3DeGeometryArray.
 
Methods inherited from class j3deditor.bin.hierarchy.J3DeGeometry
getGeometry, setCapabilities
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

J3DeGeometryArray

public J3DeGeometryArray(javax.media.j3d.GeometryArray geom)
Creates an instance of J3DeGeometryArray.

Parameters:
geom - GeometryArray which data this J3DeGeometryArray manages
Method Detail

setCapabilities

public static void setCapabilities(javax.media.j3d.GeometryArray geom)
Sets neccessary capability bits.

Parameters:
geom - GeometryArray which capability bits will be set.
See Also:
GeometryArray

getVertices

protected Vertex[] getVertices()
Returns all valid vertices.

Returns:
all valid vertices

deleteVertices

protected void deleteVertices(Vertex[] vertices)
Deletes specified vertices.

Parameters:
vertices - vertices that will be deleted

changeValidVCount

protected void changeValidVCount(int newValue)
Changes the amount of valid vertices (and restructures the array of vertices (Vertex[])).

Parameters:
newValue - new amount of valid vertices

getVertexCount

protected int getVertexCount()
Returns the amount of all vertices.

Returns:
the amount of all vertices
See Also:
GeometryArray.getVertexCount()

getVertexCoordinates

protected float[] getVertexCoordinates(int index,
                                       int[] axes)
Returns the coordinates of the specified vertex.

Parameters:
index - index of the vertex
axes - requested coordinate axes.
0 - X-axis
1 - Y-axis
2 - Z-axis
Returns:
the coordinates of the specified vertex

setVertexCoordinates

protected void setVertexCoordinates(int index,
                                    float[] coordinates,
                                    int[] axes)
Sets the coordinates of the specified vertex.

Parameters:
index - index of the vertex
coordinates - new coordinates (only those axes set by axes)
axes - coordinate axes which will be updated.
0 - X-axis
1 - Y-axis
2 - Z-axis

getTextureCoordinates

protected float[] getTextureCoordinates(int index,
                                        int[] axes,
                                        int texCoordSet)
Returns texture coordinates of the specified vertex.

Parameters:
index - index of the vertex
axes - requested texture coordinate axes.
0 - S-axis
1 - T-axis
2 - R-axis
3 - Q-axis
texCoordSet - index of the texture coordinate set
Returns:
texture coordinates of the specified vertex

setTextureCoordinates

protected void setTextureCoordinates(int index,
                                     float[] coordinates,
                                     int[] axes,
                                     int texCoordSet)
Sets texture coordinates of the specified vertex.

Parameters:
index - index of the vertex
coordinates - new coordinates (only those axes set by axes).
axes - texture coordinate axes which will be updated.
0 - S-axis
1 - T-axis
2 - R-axis
3 - Q-axis
texCoordSet - index of the texture coordinate set

getNormal

protected float[] getNormal(int index)
Returns the vertex normal of the specified vertex.

Parameters:
index - index of the vertex
Returns:
vertex normal of the specified vertex

setNormal

protected void setNormal(int index,
                         float[] coordinates)
Sets the vertex normal of the specified vertex.

Parameters:
index - index of the vertex
coordinates - normal vector values (X, Y and Z)

getColor

protected float[] getColor(int index)
Returns the color of the specified vertex.

Parameters:
index - index of the vertex
Returns:
the color of the specified vertex

setColor

protected void setColor(int index,
                        float[] color)
Sets the color of the specified vertex.

Parameters:
index - index of the vertex
color - new color (COLOR_3 or COLOR_4 according to the type of GeometryArray)

createNewGeometryArray

public static J3DeGeometryArray createNewGeometryArray(int type,
                                                       int vertexCount,
                                                       int vertexFormat)
Creates new GeometryArray with the specified properties and sets its valid vertx count to 0.

Parameters:
type - 1 - PointArray
2 - LineArray
3 - TriangleArray
4 - QuadArray
vertexCount - number of vertices
vertexFormat - a mask indicating which components are present in each vertex, see javax.media.j3d.GeometryArray flags
Returns:
J3DeGeometryArray which contains newly created GeometryArray
See Also:
GeometryArray

createSimilarGeometryArray

public J3DeGeometryArray createSimilarGeometryArray(int vertexCount,
                                                    Vertex[] vertices)
Creates and returns new J3DeGeometryArray which has same properties.

Parameters:
vertexCount - number of vertices
vertices - vertices which will be copied to new J3DeGeometryArray (valid vertices)
Returns:
new J3DeGeometryArray which has same properties

changeGeometryType

public J3DeGeometryArray changeGeometryType(int vertexFormat)
Creates new GeometryArray with the specified vertex format and vertex data from this J3DeGeometryArray.

Parameters:
vertexFormat - a mask indicating which components are present in each vertex, see javax.media.j3d.GeometryArray flags
Returns:
J3DeGeometryArray which contains newly created GeometryArray
See Also:
GeometryArray

getVertexMode

public int getVertexMode()
Returns vertex mode.
0 - normal GeometryArray
2 - BY_REFERENCE GeometryArray
3 - INTERLEAVED GeometryArray

Returns:
vertex mode

getVertexGroupMode

public int getVertexGroupMode()
Returns vertex group mode.
1 - PointArray
2 - LineArray
3 - TriangleArray
4 - QuadArray

Returns:
vertex group mode

getTexCoordType

public int getTexCoordType()
Returns the type of texture coordinates.
0 - no texture coordinates
2 - TEXTURE_COORDINATE_2
3 - TEXTURE_COORDINATE_3
4 - TEXTURE_COORDINATE_4

Returns:
the type of texture coordinates

getTexCoordSetCount

public int getTexCoordSetCount()
Returns the amount of texture coordinate sets.

Returns:
the amount of texture coordinate sets

hasNormals

public boolean hasNormals()
Returns true if vertex normals is enabled, otherwise false.

Returns:
true if vertex normals is enabled, otherwise false

hasColor

public boolean hasColor()
Returns true if vertex colors is enabled, otherwise false.

Returns:
true if vertex colors is enabled, otherwise false

getColorType

public int getColorType()
Returns the type of vertex colors.
0 - no vertex colors
3 - COLOR_3
4 - COLOR_4

Returns:
the type of vertex colors

toString

public java.lang.String toString()
Returns the String representation of this J3DeGeometryArray.

Overrides:
toString in class java.lang.Object
Returns:
the String representation of this J3DeGeometryArray